<template>
  <div id="sendComment">
    <van-field
      v-model.trim="comment"
      rows="1"
      autosize
      type="textarea"
      placeholder="发条友善的评论吧~"
      class="sendCom"
    >
    <template #button>
      <van-button @click="onSend" plain size="small" type="primary">发送</van-button>
    </template></van-field>
  </div>
</template>

<script>
import { sendOrdelComment } from '@/api/comment.js'
export default {
  name: 'SendComment',
  data () {
    return {
      comment: ''
    }
  },
  props: {
    t: {
      type: Number,
      required: true
    },
    id: {
      type: [Number, String],
      required: true
    }
  },
  // 定义方法
  methods: {
    async onSend () {
      if (this.comment) {
        try {
          const res = await sendOrdelComment({
            type: 0,
            comment: this.comment,
            t: this.t,
            id: this.id
          })
          console.log(res)
        } catch (err) {
          console.dir(err)
        }
      }
    }
  }
}
</script>

<style scoped lang="less">
#sendComment {
  position: fixed;
  bottom: 0;
  display: flex;
  width: 100%;
  box-shadow: 0 15px 35px 10px rgba(0, 0, 0, .5);
}
</style>
